home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-22 | 2.7 KB | 77 lines | [TEXT/GEOL] |
- Item 7145868 21-Dec-89 08:03
-
- From: D5369 Mgmt Sys Des, Chuck McMath,PRT
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: Associating Two Files - How?
-
- I am writing an MacApp application which creates documents that refer to other
- documents. For instance, say Document A refers to Document B. What parameters
- can I store in DocA that will enable me to open DocB when DocA is opened?
-
- My _current_ guess is the following are the minimum parameters necessary to
- locate a file: 1. the volume name, 2. the file name (DocB's name in this case),
- and 3. the directory ID where DocB resides. I initially tried using the file
- name and its vRefNum, but have discovered that vRefNums can change from time to
- time, and I lose track of my documents.
-
- Unfortunately, I am still having trouble reopening my associated documents.
- For instance, I open DocA, my application looks and sees that DocB is not open.
- If the user wants to open DocB then I try to, and fail (with a -43 OSErr in
- ReadFromFile). TMyApp.OpenOld checks docs of type A when they are opened, and
- if their DocBs are not around, calls OpenOtherDoc, which does the following (a
- FileIDRec is defined as:
-
- FileIDRec = RECORD
- volName: Str255; { volume where file is stored }
- name: Str255; { name of the file }
- dirID: LongInt;{ the file's directory ID }
- END;)
-
- PROCEDURE TMyApp.OpenOtherDoc(theIDRec: FileIDRec);
- VAR
- theAppFile:AppFile;
- theVolRec: WDPBRec;
- tempStr: Str255;
- tempVRefNum: INTEGER;
- tempStr2: Str255;
- theVRefNum:INTEGER;
- BEGIN
- FailOSErr(GetVol(@tempStr, tempVRefNum));
- FailOSErr(SetVol(@theIDRec.volName, 0));
- FailOSErr(GetVol(@tempStr2, theVRefNum));
-
- WITH theVolRec DO
- BEGIN
- ioCompletion := NIL;
- ioNamePtr := NIL;
- ioVRefNum := theVRefNum;
- ioWDDirID := theIDRec.dirID;
- END;
-
- FailOSErr(PBHSetVol(@theVolRec, FALSE));
- FailOSErr(GetVol(@tempStr2, theVRefNum));
-
- WITH theAppFile DO
- BEGIN
- vRefNum := theVRefNum;
- fType := kOtherFileType;
- versNum := 0;
- fName := theIDRec.name;
- END;
-
- OpenOld(cOpenOtherDoc, theAppFile);
- END; { TMyApp.OpenOtherDoc }
-
- The problem is that OpenOld fails in ReadFromFile with a -43 error (file not
- found), so I am obviously not setting the directory correctly. Since OpenOld's
- only file parameter is an AppFile record, I need to pass the file name (which I
- have) and the file vRefNum (which I can't seem to get).
-
- Any clues anyone?
-
- By the way, I'm not yet on MACAPP.TECH$, so please link any responses to my
- account. Thanks in advance, fellow MacApp'ers…
-
-